package it.uniroma2.structure;

import java.util.Vector;

public class VariableService extends Variable {
	private Vector<Parameter> associatedParameter;
	private String messageType;
	private Service service;
	private String part;
	
	public VariableService(String name, Service service, boolean input) {
		super(name);
		this.associatedParameter = new Vector<Parameter>();
		this.service = service;
		if(input && service != null){
			String messageType = this.service.getInputMessage();
		}else if(service != null){
			String messageType = this.service.getOutputMessage();
		}
		
	}
	
	
//	public VariableService(String name, String messageType, Parameter p) {
//		super(name);
//		this.associatedParameter = new Vector<Parameter>();
//		this.setMessageType(messageType);
//	}
	
	
//	public VariableService(String nameVar, String msgtype, Parameter tempPI, Service serviceNode) {
//		this(nameVar, msgtype, tempPI);
//		this.service = serviceNode;
//	}


	@Override
	public boolean equals(Object obj) {
		return (((Variable)obj).getName().equals(this.getName()));
	}
	
	
	public Vector<Parameter> getAssociatedParameter() {
		return associatedParameter;
	}
	
	
	public void setAssociatedParameter(Parameter associatedParameter) {
		this.associatedParameter.addElement(associatedParameter);
	}
	
	
	public void setAssociatedParameter(Vector<Parameter> associatedParameters) {
		this.associatedParameter = associatedParameters;
	}
	
	
	@Override
	public String toString() {
		return super.toString() + " messageType=\"" + this.service.getCompatNS() + ":" + messageType + "\"";
	}
	
	
	@Override
	public String toBPEL() {
		return "<" + super.variableTag + " " + this.toString() + "/>\n";
	}
	
	
	public String getMessageType() {
		return messageType;
	}
	
	
	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}
	
	public String getPart(){
		return this.part;
	}
	
	
	public void setPart(String part){
		this.part = part;
	}
	
	
	public String getNamespace() {
		return this.service.getCompatNS();
	}
	
	public Service getService(){
		return this.service;
	}
}
